﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Script.Serialization;

/// <summary>
/// Summary description for ToJson
/// </summary>
public static class Json
{
    public static string ToJson(this object obj)
    {
        JavaScriptSerializer serializer = new JavaScriptSerializer();
        serializer.RecursionLimit = int.MaxValue;
        return serializer.Serialize(obj);
    }
    public static T ToObject<T>(this string obj)
    {
        JavaScriptSerializer serializer = new JavaScriptSerializer();
        serializer.RecursionLimit = int.MaxValue;
        return serializer.Deserialize<T>(obj);
    }
}